Foreground-Background Separation Using Codebook Model